<?php
namespace Admin\Controller;

use Think\Controller;

class SystemController extends CommonController
{
    private $user;
    private $information;

    public function __construct()
    {

        parent::__construct();
        $this->user = M("user");
        $this->information = M("information");

    }

    function password_change()
    {

        $this->display();
    }

    function do_password()
    {
        $System = D("System");
        if (!$System->create()) {
            // 如果创建失败 表示验证没有通过 输出错误提示信息
            $this->error($System->getError());
        } else {
            // 验证通过 可以进行其他数据操作

            $System->save();
            $this->success("修改密码成功", U("Admin/user/logout"));
        }
        /*$id = I("post.id");
        $new_password = substr(md5(trim(I("POST.new_password"))), 6, -6);
        //echo ($new_password);
        //exit;
        $this->user->where("id=$id")->setField("password", $new_password);


        $this->success("修改密码成功", U("Admin/user/logout"));*/

    }

    function information()
    {

        $information = $this->information->select();
        $this->assign("information", $information);
        $this->display();
    }

    function do_information()
    {
        //dump($_POST);
       // exit;
        $this->information->create();
        $this->information->save();
        //echo $this->information->getLastSql();
        //exit;
        $this->success("修改成功", U("Admin/index/index"));
    }


    function clear_cache()
    {
        delDir(RUNTIME_PATH);
        $this->success('清除成功');
    }


    function ck_finder()
    {
        $this->display();
    }


}